<?php

namespace App\Http\Controllers\Domain;


use App\Http\Controllers\Controller;
use App\Helper;
use App\Http\Requests\PlayerChangePwdRequest;
use App\Models\Character;
use App\Models\Server;
use App\Models\Video;
use Illuminate\Support\Facades\Response;

class LauncherController extends Controller
{
    public $prefix='domain';

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index($domain)
    {
        $server=Server::where('domain',$domain)->first();
        if ($server->enable){
            return view($this->prefix.'.index'.$server->template,compact('server'));
        }else{
            return '此服务器已经停止运营! 如有疑问，请联系客服：'.$server->qq_server;
        }
    }

    /**
     * 下载登录器
     * @param $domain
     * @return int
     */
    public function launcher($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}
        return $server->DownLoadLauncher();
    }

    public function patchlist($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}
        return $server->launcherConfig->patchlist;
    }
    public function patchtodel($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}
        return $server->launcherConfig->patchtodel;
        return 'patch-zhCN-666.MPQ';
    }
    public function version($domain){
        return config('conf.LauncherVer');
    }
    public function news($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}
        $res=$server->launcherConfig->news;
        if ($res=='') $res="{$server->name}##http://hx.phasercn.com/download/text_mod/01.jpg#http://{$server->getDomain()}";
        return $res;
    }
    public function updates($domain){
        return '2023/03/29 - (v2.3.0.2)
- 调整界面布局。
- 添加服务器名称显示。';
    }
    public function realmlist($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}
        return "set realmlist {$server->server_host}";
    }

    public function links($domain){
        $server=Server::where('domain',$domain)->first();
        if (!$server->enable){return 0;}

        $domain='http://'.$server->getDomain();
        return $server->name.','
            .$domain.','
            .$domain.'/user/recharge'.','
            .$domain.'/user/mall'.','
            .$server->launcherConfig->links.','
            .',,';
    }


}
